<?php
require_once BASE_PATH . 'application/models/basedao' . EXT;
class joomlaDAO extends baseDAO {

    function __construct() {
        // Call the Model constructor
        parent::__construct();

        define('_JEXEC', 1);
        define('JPATH_BASE', BASE_PATH); // assuming we are in the authorisation plugin folder and need to go up 3 steps to get to the Joomla root

        require_once (JPATH_BASE . DS . 'includes' . DS . 'defines.php');
        require_once (JPATH_BASE . DS . 'includes' . DS . 'framework.php');
        require_once (JPATH_BASE . DS . 'libraries' . DS . 'joomla' . DS . 'user' . DS . 'authentication.php');

        $mainframe = & JFactory::getApplication('site');
        $mainframe->initialise();
    }

    function getCryptedPassword($password) {
        jimport('joomla.user.helper');

        $salt = JUserHelper::genRandomPassword(32);
        $crypt = JUserHelper::getCryptedPassword($password, $salt);
        return $crypt . ':' . $salt;
    }

}

?>